﻿<UserControl x:Class="TorchView.FileStore.FileStoreView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:TorchView.FileStore" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
  <UserControl.Resources>

    <DataTemplate DataType="{x:Type local:GameFileViewModel}">
      <DataTemplate.Resources>
        <Style TargetType="TextBlock">
          <Setter Property="VerticalAlignment" Value="Center" />
          <Setter Property="Foreground" Value="{StaticResource HighlightedTextBrush}" />
        </Style>
      </DataTemplate.Resources>
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="50" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <TextBlock Text="{Binding Name}" Margin="4" FontSize="20" />
        <StackPanel Orientation="Vertical" Grid.Row="2" Grid.Column="1" Grid.RowSpan="2" Margin="4">
          <Button Content="Store" Command="{Binding StoreFileCommand}" Margin="2" />
          <Button Content="Download" Command="{Binding DownloadFileCommand}" Margin="2" />
          <Button Content="Edit Comment" Command="{Binding EditCommentCommand}" Margin="2" />
          <Button Content="Delete" Command="{Binding DeleteFileCommand}" Margin="2" />
        </StackPanel>

        <TextBlock Text="Repository files:" Grid.Row="2" FontSize="16" />
        <DataGrid Grid.Row="3" ItemsSource="{Binding Files}" HorizontalAlignment="Stretch" IsSynchronizedWithCurrentItem="True" Background="{x:Null}" BorderThickness="0" CanUserResizeRows="False" CanUserResizeColumns="False" HorizontalScrollBarVisibility="Hidden" RowDetailsVisibilityMode="Collapsed" RowHeaderWidth="1" SelectionMode="Single" SelectionUnit="FullRow" HorizontalContentAlignment="Stretch" RowBackground="{x:Null}" HorizontalGridLinesBrush="{StaticResource UnhighlightedTextBrush}" VerticalGridLinesBrush="{StaticResource UnhighlightedTextBrush}" FontSize="16" CanUserSortColumns="True" Sorting="DataGrid_Sorting" IsReadOnly="True">
          <DataGrid.CellStyle>
            <Style TargetType="DataGridCell">
              <Setter Property="Background" Value="Transparent" />
              <Setter Property="BorderThickness" Value="0" />
              <Setter Property="Padding" Value="4,2" />
              <Setter Property="Foreground" Value="{StaticResource UnhighlightedTextBrush}" />
              <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                  <Setter Property="Background" Value="{StaticResource SelectedBackgroundBrush}" />
                  <Setter Property="Foreground" Value="{StaticResource HighlightedTextBrush}" />
                </Trigger>
              </Style.Triggers>
            </Style>
          </DataGrid.CellStyle>
          <DataGrid.ColumnHeaderStyle>
            <Style TargetType="DataGridColumnHeader">
              <Setter Property="Background" Value="{StaticResource BackgroundGradient}" />
              <Setter Property="Foreground" Value="White" />
              <Setter Property="BorderBrush" Value="{StaticResource UnhighlightedTextBrush}" />
              <Setter Property="BorderThickness" Value="0,1,1,1" />
              <Setter Property="Padding" Value="4,2" />
            </Style>
          </DataGrid.ColumnHeaderStyle>
          <DataGrid.Columns>
            <DataGridTextColumn Header="Version" Binding="{Binding Version}"  CanUserSort="True" />
            <DataGridTextColumn Header="Store Date" Binding="{Binding StoreDate}" CanUserSort="True" />
            <DataGridTextColumn Header="Comments" Binding="{Binding Comments}" Width="*" CanUserSort="True" />
          </DataGrid.Columns>
        </DataGrid>
      </Grid>
    </DataTemplate>

  </UserControl.Resources>
  <Border CornerRadius="2" Background="#20FFFFFF" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1">
    <TabControl ItemsSource="{Binding Files}" Style="{StaticResource DefaultTabControlStyle}" IsSynchronizedWithCurrentItem="True">
      <TabControl.ItemTemplate>
        <DataTemplate>
          <TextBlock Text="{Binding Name}" />
        </DataTemplate>
      </TabControl.ItemTemplate>
    </TabControl>
  </Border>
</UserControl>
